//
//  LYDPopView.m
//  20150809生活圈
//
//  Created by yons on 15/8/11.
//  Copyright (c) 2015年 iron. All rights reserved.
//

#import "LYDPopView.h"
#import "LYDTabBarViewAndPopViewDelegate.h"
@implementation LYDPopView

- (instancetype)initWithFrame:(CGRect)frame
{
    if (self = [super initWithFrame:frame]) {
        UIImageView *backgroudView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, UIScreenWidth, PopViewHeight)];
        backgroudView.image = [UIImage imageNamed:@"home_topbar"];
        backgroudView.userInteractionEnabled = YES;
        [self addSubview:backgroudView];
        CGFloat imageW = 640;
        UIButton *serviceBtn = [LYDFactory LYDButtonwithType:LYDNormalButton WithFrame:CGRectMake(0, 0, UIScreenWidth * (160 / imageW), PopViewHeight) withTitle:@"社区服务" withTag:5];
        [serviceBtn addTarget:self action:@selector(popViewButtonClick:) forControlEvents:UIControlEventTouchUpInside];
        UIButton *liveToolBtn = [LYDFactory LYDButtonwithType:LYDNormalButton WithFrame:CGRectMake(UIScreenWidth * (160 / imageW), 0, UIScreenWidth * (185 / imageW), PopViewHeight)  withTitle:@"生活工具" withTag:6];
        [liveToolBtn addTarget:self action:@selector(popViewButtonClick:) forControlEvents:UIControlEventTouchUpInside];
        UIButton *aroundBtn = [LYDFactory LYDButtonwithType:LYDNormalButton WithFrame:CGRectMake(UIScreenWidth * (160 / imageW) + UIScreenWidth * (185 / imageW), 0, UIScreenWidth * (135 / imageW), PopViewHeight)  withTitle:@"周边" withTag:7];
        [aroundBtn addTarget:self action:@selector(popViewButtonClick:) forControlEvents:UIControlEventTouchUpInside];
        UIButton *backBtn = [LYDFactory LYDButtonwithType:LYDNormalButton WithFrame:CGRectMake(UIScreenWidth * (160 / imageW) + UIScreenWidth * (185 / imageW) + UIScreenWidth * (135 / imageW), 0, UIScreenWidth * (120 / imageW), PopViewHeight)  withTitle:@"收起" withTag:8];
        [backBtn addTarget:self action:@selector(popViewButtonClick:) forControlEvents:UIControlEventTouchUpInside];
        [self addSubview:serviceBtn];
        [self addSubview:liveToolBtn];
        [self addSubview:aroundBtn];
        [self addSubview:backBtn];
    }
    return self;
}

- (void)popViewButtonClick:(UIButton *)btn
{
    NSLog(@"pop");
    if ([self.delegate respondsToSelector:@selector(changeControllerWithButton:)]) {
        [self.delegate changeControllerWithButton:btn];
    }
}


@end
